# -*- coding:utf8 -*-

from flask import render_template
from flask import request, current_app

from b2c.controllers.admin import a_bp
# from . import validate_arg
# from lyra.service import UserService, AlbumService, ScoreService
# from lyra.controllers.web.validators import ShareMp3Input
#

import hashlib
import base64
import urllib


@a_bp.route('/', methods=['GET', 'POST'])
def index():
    args = request.args
    args_json = request.json
    if args:
        msg = args.get('msg')
        nonce = args.get('nonce')
        signature = args.get('signature')
        token = 'abc'
        _md5 = hashlib.md5((token + nonce + msg).encode('utf-8')).hexdigest()
        encodestr = base64.b64encode(_md5.encode('utf-8'))
        # xx = urllib.parse.qu
        return msg
    elif args_json:
        print (args_json)
        return 'recived'
    else:
        return u'非法请求，请通过onenet配置url后上传数据'